package task5.chat;

import java.io.*;
import java.net.ServerSocket;
import java.net.Socket;

/**
 * 聊天服务器端
 */
public class ChatServer {
    public static void main(String[] args) throws IOException {
        // 创建ServerSocket对象，并且指定端口
        ServerSocket serverSocket = new ServerSocket(9001);
        while (true){
            // 服务器开始接收
            Socket socket = serverSocket.accept();
            ChatChannel chatChannel = new ChatChannel(socket);
            // 每个通道添加到通道列表里
            ChatChannel.chat_list.add(chatChannel);
            Thread thread = new Thread(chatChannel);
            thread.start();
        }
    }
}
